#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string shu;
    cin >> shu;
    int len = shu.size();
    int box = 0;
    for (int i = 0; i < len; i++) {
      int k = shu[i] - '0';
      int cj = 1;
      for (int j = 1; j <= len; j++) {
        cj = cj * k;
      }
      box += cj;
    }

    if (to_string(box) == shu)
      cout << "T";
    else
      cout << "F";
  }
  


  return 0;
}